import { Component, Fragment, createRef, forwardRef } from "react"
import PropTypes from 'prop-types'
import { Card } from 'antd-mobile'
// import axios from 'axios'

const RerBtn = forwardRef(function (props, ref) {
  return <button color='primary' ref={ref} onClick={() => props.fun(ref)}>删除服务</button>
})

export class TestChild extends Component {
  constructor(props) {
    super(props)
    this.state = {}
    this.removeService = this.removeService.bind(this)
    this.ref = createRef()
  }

  removeService(e) {
    console.log('removeService', e)
    this.props.removeFun(this.props.content)
  }

  async componentDidMount(aa) {

  }

  render() {
    return (
      <Fragment>
        <Card title='卡片标题'>
          <span dangerouslySetInnerHTML={{__html:this.props.content.text}}></span>
          {/* <Button color='primary' onClick={this.props.removeFun}>删除服务</Button> */}
          <RerBtn ref={this.ref} fun={this.removeService}></RerBtn>
        </Card>
        
      </Fragment>
    )
  }
}

TestChild.propTypes = {
  content: PropTypes.object
}